#include <allegro.h>
#include <stdio.h>

#define GFX_W 800
#define GFX_H 600
#define nb_images_bonus 3

typedef struct {
	BITMAP *img_right=NULL;
	BITMAP *img_left=NULL;
	BITMAP *img_kid=NULL;
        BITMAP *bonus_exp[nb_images_bonus];
	int x, y;
}Rebecca ;

//Bech tcharji background :
//Module Background

BITMAP* load_background_bmp(char chemin_background[]);
void draw_background(BITMAP *Background,BITMAP*Buffer);
void destroy_background(BITMAP * Background);


//Bech tcharji personnage:

void load_Rebecca(Rebecca *R);
void destroy_Rebecca(Rebecca *R);
void init_Rebecca(Rebecca *R);



/*
 * module background
 */

BITMAP* load_background_bmp(char chemin_background[])
{
	BITMAP* Background;

	Background=load_bitmap(chemin_background, NULL);
	if(Background == NULL){
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Unable to load image !\n%s\n", allegro_error);
		return (NULL);
	}
	return (Background);

}
void draw_background(BITMAP *Background,BITMAP*Buffer)
{
	blit(Background, Buffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}

void destroy_background(BITMAP * Background)
{
	destroy_bitmap(Background);
}


void load_Rebecca(Rebecca *R)
{
int i;
char tmp[60];
	R->img_right=load_bitmap("../images/right.bmp", NULL);
	R->img_left=load_bitmap("../images/left.bmp", NULL);
	
	for (i = 0; i <= nb_images_bonus; i++) 
	{
	sprintf(tmp, "../images/rep%d.bmp", i);
	R->bonus_exp[i]=load_bitmap(tmp, NULL);
	}

}

void init_Rebecca(Rebecca *R)
{
	
	R->x =500 ;
	R->y =400 ;
}



void destroy_Rebecca(Rebecca *R)
{
	int i;
		destroy_bitmap(R->img_right);
		destroy_bitmap(R->img_left);

	for (i = 0; i <= nb_images_bonus; i++) {
		destroy_bitmap(R->bonus_exp[i]);
	}

}

// MODULE REBECCA BONUS //
void draw_Rebecca_bonus (Rebecca *R,BITMAP *Buffer, int indice)
{
	draw_sprite(Buffer, R->img_bonus_exp[indice],Rebecca->x, Rebecca->y);
}


void affiche_Rebecca_bonus(Rebecca *R,int *rep ,BITMAP * Background)
{
if (rep==0) {
     draw_rebecca_bonus(R,Background,0);
}
else if (rep==1) {
     draw_rebecca_bonus(R,Background,1);
}
else if (rep==2) {
     draw_rebecca_bonus(R,Background,2);
}
}

// MODULE REBECCA STAGE //

void draw_rebecca_stage( Rebecca *R, BITMAP *Buffer, int *stage)
{
	if ((*stage)==3)
	{
	draw_sprite(Buffer, R->img_kid,500, 400);

}
// INCOMPLET //
void depl_alea (Pirate *P, Rebecca *R, BITMAP *Background)
{
//R->x -=  (vitesse) ;

//P->x -= (vitesse) ;
}



